package de.velvettear.squirrel.util;

import java.util.Random;
import java.util.Vector;

import de.velvettear.squirrel.kernel.Password;
import android.util.Log;

public class PasswordHelper {

	public static Password generatePassword(int length, boolean lowerCase, boolean upperCase, boolean numeric, boolean specialChars) {
		Log.i("generatePassword()", "BEGIN");
		String password = "";
		
		Vector<Integer> chars = BruteForceHelper.getBruteForceChars(lowerCase, upperCase, numeric, specialChars);
		int charCount = chars.size();
		for (int counter = 0; counter < length; counter++) {
			Random numberGenerator = new Random();
			int random = numberGenerator.nextInt(charCount);
			password += (char) ((int) chars.elementAt(random));
		}
		Log.i("generatePassword()", "PASSWORD " + password + " GENERATED");
		
		Password pass = new Password();
		pass.m_sValue = password;
		
		Log.i("generatePassword()", "END");
		return pass;
	}
	
}
